<?php
echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/table-sorter/jquery.dataTables.js');
		
$permission_arr = array('add_enable' => $this->allow('add','backend','Articles'), 'edit_enable' => $this->allow('edit','backend','Articles'), 'publish_enable' => $this->allow('publish','backend','Articles'), 'delete_enable' => $this->allow('delete','backend','Articles'));
	
?>
<style type="text/css">
/*
    ColorBox Core Style
    The following rules are the styles that are consistant between themes.
    Avoid changing this area to maintain compatability with future versions of ColorBox.
*/
#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden;}
#cboxOverlay{position:fixed; width:100%; height:100%;}
#cboxMiddleLeft, #cboxBottomLeft{clear:left;}
#cboxContent{position:relative; overflow:hidden;}
#cboxLoadedContent{overflow:auto;}
#cboxLoadedContent iframe{display:block; width:100%; height:100%; border:0;}
#cboxTitle{margin:0;}
#cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%;}
#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}

/* 
    Example user style
    The following rules are ordered and tabbed in a way that represents the
    order/nesting of the generated HTML, so that the structure easier to understand.
*/
#cboxOverlay{background:url(css/jqueryCSS/colorbox/example1/images/overlay.png) 0 0 repeat;}
#colorbox{}
    #cboxTopLeft{width:21px; height:21px; background:url(css/jqueryCSS/colorbox/example1/images/controls.png) -100px 0 no-repeat;}
    #cboxTopRight{width:21px; height:21px; background:url(css/jqueryCSS/colorbox/example1/images/controls.png) -129px 0 no-repeat;}
    #cboxBottomLeft{width:21px; height:21px; background:url(css/jqueryCSS/colorbox/example1/images/controls.png) -100px -29px no-repeat;}
    #cboxBottomRight{width:21px; height:21px; background:url(css/jqueryCSS/colorbox/example1/images/controls.png) -129px -29px no-repeat;}
    #cboxMiddleLeft{width:21px; background:url(css/jqueryCSS/colorbox/example1/images/controls.png) left top repeat-y;}
    #cboxMiddleRight{width:21px; background:url(css/jqueryCSS/colorbox/example1/images/controls.png) right top repeat-y;}
    #cboxTopCenter{height:21px; background:url(css/jqueryCSS/colorbox/example1/images/border.png) 0 0 repeat-x;}
    #cboxBottomCenter{height:21px; background:url(css/jqueryCSS/colorbox/example1/images/border.png) 0 -29px repeat-x;}
    #cboxContent{background:#fff;}
        #cboxLoadedContent{margin-bottom:28px;}
        #cboxTitle{position:absolute; bottom:4px; left:0; text-align:center; width:100%; color:#949494;}
        #cboxCurrent{position:absolute; bottom:4px; left:58px; color:#949494;}
        #cboxSlideshow{position:absolute; bottom:4px; right:30px; color:#0092ef;}
        #cboxPrevious{position:absolute; bottom:0; left:0px; background:url(css/jqueryCSS/colorbox/example1/images/controls.png) -75px 0px no-repeat; width:25px; height:25px; text-indent:-9999px;}
        #cboxPrevious.hover{background-position:-75px -25px;}
        #cboxNext{position:absolute; bottom:0; left:27px; background:url(css/jqueryCSS/colorbox/example1/images/controls.png) -50px 0px no-repeat; width:25px; height:25px; text-indent:-9999px;}
        #cboxNext.hover{background-position:-50px -25px;}
        #cboxLoadingOverlay{background:url(css/jqueryCSS/colorbox/example1/images/loading_background.png) center center no-repeat;}
        #cboxLoadingGraphic{background:url(css/jqueryCSS/colorbox/example1/images/loading.gif) center center no-repeat;}
        #cboxClose{position:absolute; bottom:0; right:0; background:url(css/jqueryCSS/colorbox/example1/images/controls.png) -25px 0px no-repeat; width:25px; height:25px; text-indent:-9999px;}
        #cboxClose.hover{background-position:-25px -25px;}
</style>
<script type="text/javascript">
$(document).ready(function() {
	
	floatingbar('#floatingbar',"#button_top_bar",null);
	
	/****************************Sorting Table Start*********************/
	var oTable = $("#sortTable").dataTable({
				"bPaginate": false,
				"bLengthChange": true,
				"bSearchable": true,
				"bFilter": true,
				"bSort": true,
				"bInfo": false,
				"bAutoWidth": true,
				"bProcessing": false,
				"bSortClasses": true,
				"bStateSave": false,
				"bServerSide": false,
				"aaSorting": [[ 1, "asc" ]],				
				"aoColumnDefs": [ 
						{ "bSortable": false, "bSortClasses": false,  "aTargets": [ 0 ] }
					],
				"oLanguage" : { "sSearch": "<?php echo $this->translator->translator('jquery_filter'); ?>" }
			}); 	
	
	$('td', oTable.fnGetNodes()).hover( function() {		
		$(this).parents("tr:first").children('td').addClass( 'highlighted' );
	}, function() {
		$('td.highlighted').removeClass('highlighted');
	});
	
	/* Get the rows which are currently selected */
	function fnGetSelected( oTableLocal )
	{
		var aReturn = new Array();
		var aTrs = oTableLocal.fnGetNodes();
		
		for ( var i=0 ; i<aTrs.length ; i++ )
		{
			if ( $(aTrs[i]).hasClass('row_selected') )
			{
				aReturn.push( aTrs[i] );
			}
		}
		return aReturn;
	}
	
	lastClassAdd(oTable);
	/****************************Sorting Table End*********************/	
	
	function openMsgDialog(msg)
	{
		$.fx.speeds._default = 1000;
		$('#dialog_container').html(msg).dialog({
					autoOpen: true,
					modal: false,
					show: 'fade',
					resizable: 'false',				
					buttons: { "<?php echo html_entity_decode($this->translator->translator('common_ok'), ENT_QUOTES, "UTF-8"); ?>": function() { $(this).dialog('option', 'hide', 'explode').dialog("close"); } },
					open: function(event, ui)
						 {
							setTimeout(function() 
							{									
								if($('#' + event.target.id).dialog('isOpen'))
								{
									$('#' + event.target.id).dialog('option', 'hide', 'explode').dialog('close');										
								}
							}, 10000);
						  }
				});
	}
	
	function deleteThis(self)
	{		
		var arr = $(self).attr('rel').split('_');
		$.ajax({
			 url: "<?php echo $this->url( array('module'=> 'Articles', 'controller' => 'backend', 'action'     => 'delete' ), 'adminrout',    true) ?>",
			 type: 'POST',
			 data: { article_id: arr[0], article_title: arr[1] },
			 beforeSend: function(){
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/loader/ajax_loader.gif" height="16" border="0" />');
				 },
			 success: function(response) 
			 {
			 	//alert(response);
			 	var json_arr = eval("("+response+")");
				if(json_arr.status == 'ok')
				{
					$(self).parents("li:first").parents("ul:first").parents("td:first").parents("tr:first").addClass('row_selected');
						var oTables = $('#sortTable').dataTable();
						var anSelected = fnGetSelected( oTables );
						oTables.fnDeleteRow( anSelected[0] );
						lastClassAdd(oTables);
			 	}
			 },
			error: function(xhr, status, error){				
				var msg = "Error! " + xhr.status + " " + error;
				openMsgDialog(msg);
			}
		});
	}
	
	$('a.delete_btn').click(function() {
		var self = this;
		$("#dialog-confirm").html("<?php echo addslashes($this->translator->translator('article_list_delete_confirm')); ?>").dialog({
			resizable: false,
			width:400,
			height:170,
			modal: true,
			show: 'fade',
			hide: 'explode',
			buttons: {
					'<?php echo html_entity_decode($this->translator->translator("common_delete"), ENT_QUOTES, "UTF-8"); ?>': function() {
					deleteThis(self);
					$(this).dialog('close');
				},
			'<?php echo html_entity_decode($this->translator->translator("common_cancel"), ENT_QUOTES, "UTF-8"); ?>': function() {
					$(this).dialog('close');
				}
			}
		});
	});
	
	$('a.up_btn').click(function() {
		var self = this;				
		var arr = $(self).attr('rel').split('_');		
		var prev_order = $(self).parents("td:first").children("input:nth-child(1)").val();		
		$.ajax({
				 url: "<?php echo $this->url( array('module'=> 'Articles', 'controller' => 'backend', 'action'     => 'up' ), 'adminrout',    true) ?>",
				 type: 'POST',
				 data: { article_id: arr[0], order: prev_order},
				 beforeSend: function(){
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/up-animation.gif" border="0" />');
				 },
				 success: function(response) 
				 {
				 	//alert(response);
					var json_arr = eval("("+response+")");
					if(json_arr.status == 'ok')
					{
						$(self).parents("td:first").children("input:nth-child(1)").val((prev_order-1));
						if(json_arr.id_arr != '' && json_arr.id_arr != null)
						{
							for(var i = 0; i < json_arr.id_arr.length; i++)
							{
								for(var j=0;j < $('a.up_btn').length ;j++)
								{
									var arrUp = $('a.up_btn:eq('+j+')').attr('rel').split('_');									
									if(arrUp[0] == json_arr.id_arr[i])	
									{										
										$('a.up_btn:eq('+j+')').parents("td:first").children("input:nth-child(1)").val(prev_order);
									}					
								}
							}							
						}						
					}
					else
					{
						openMsgDialog(json_arr.msg);
					}
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/up-arrow.gif" border="0" />');
				 }
			});
	});	
	
	$('a.down_btn').click(function() {
		var self = this;				
		var arr = $(self).attr('rel').split('_');		
		var prev_order = $(self).parents("td:first").children("input:nth-child(1)").val();		
		
		$.ajax({
				 url: "<?php echo $this->url( array('module'=> 'Articles', 'controller' => 'backend', 'action'     => 'down' ), 'adminrout',    true) ?>",
				 type: 'POST',
				 data: { article_id: arr[0], order: prev_order},
				 beforeSend: function(){
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/down-animation.gif" border="0" />');
				 },
				 success: function(response) 
				 {
				 	// alert(response);
					var json_arr = eval("("+response+")");
					if(json_arr.status == 'ok')
					{
						var new_order = parseInt(prev_order) + 1;
						$(self).parents("td:first").children("input:nth-child(1)").val(new_order);
						if(json_arr.id_arr != '' && json_arr.id_arr != null)
						{
							for(var i = 0; i < json_arr.id_arr.length; i++)
							{
								for(var j=0;j < $('a.up_btn').length ;j++)
								{
									var arrUp = $('a.up_btn:eq('+j+')').attr('rel').split('_');									
									if(arrUp[0] == json_arr.id_arr[i])	
									{										
										$('a.up_btn:eq('+j+')').parents("td:first").children("input:nth-child(1)").val(prev_order);
									}					
								}
							}							
						}						
					}
					else
					{
						openMsgDialog(json_arr.msg);
					}
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/down-arrow.gif" border="0" />');
				 }
			});
	});
	
	
	$('a.all_order_btn').click(function() {
		var self = this;
		var order_str = '';
		var article_id_str = '';
		for(var i=0;i<$('input.order_text').length;i++)
		{
			if(i == 0)
			{
				order_str += $('input.order_text:eq('+i+')').val();
				article_id_str += $('input.order_text:eq('+i+')').parents("td:first").children("a:first").attr('rel');
			}
			else
			{
				order_str += ','+$('input.order_text:eq('+i+')').val();
				article_id_str += ','+$('input.order_text:eq('+i+')').parents("td:first").children("a:first").attr('rel');
			}
		}
		
		$.ajax({
				 url: "<?php echo $this->url( array('module'=> 'Articles', 'controller' => 'backend', 'action'     => 'orderall' ), 'adminrout',    true) ?>",
				 type: 'POST',
				 data: { article_id_arr: article_id_str, order_arr: order_str},
				 beforeSend: function(){
				 	oTable.fnSettings().aoColumns[4].bSortable = false;
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/loader/ajax_loader.gif" height="16" border="0" />');
				 },
				 success: function(response) 
				 {
				 	//alert(response);
					var json_arr = eval("("+response+")");
					openMsgDialog(json_arr.msg);
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/save.png" border="0" />');
					oTable.fnSettings().aoColumns[4].bSortable = true;
				 }
		});
	});
	
	$('a.publish_btn').click(function() {
		var self = this;
		<?php if ($permission_arr['publish_enable']) { ?>		
		var arr = $(self).attr('rel').split('_');
		$.ajax({
			 url: "<?php echo $this->url( array('module'=> 'Articles', 'controller' => 'backend', 'action'     => 'publish' ), 'adminrout',    true) ?>",
			 type: 'POST',
			 data: { article_id: arr[0], article_title: arr[1], paction: arr[2]},
			 beforeSend: function(){
				$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/loader/ajax_loader.gif" height="16" border="0" />');
			},
			 success: function(response) 
			 {
			 	//alert(response);
			 	var json_arr = eval("("+response+")");
				if(json_arr.status == 'ok')
				{
					if(json_arr.article_status == '1')
					{
						//$(self).parents("td:first").parents("tr:first").parents("table:first").parents("td:first").parents("tr:first").children("td:nth-child(6)").html('<?php echo $this->translator->translator("common_published_language"); ?>');
						$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/published.gif" border="0" title="<?php echo $this->translator->translator("common_unpublish_title"); ?>" />').attr('rel',arr[0]+"_"+arr[1]+"_unpublish");
					}
					else
					{
						//$(self).parents("td:first").parents("tr:first").parents("table:first").parents("td:first").parents("tr:first").children("td:nth-child(6)").html('<?php echo $this->translator->translator("common_unpublished_language"); ?>');
						$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/unpublished.gif" border="0" title="<?php echo $this->translator->translator("common_publish_title"); ?>" />').attr('rel',arr[0]+"_"+arr[1]+"_publish");
					}
			 	}
				else
				{
					openMsgDialog(json_arr.msg);
				}
			 },
			error: function(xhr, status, error){				
				var msg = "Error! " + xhr.status + " " + error;
				openMsgDialog(msg);
			}
		});
		<?php }else{ ?>
			var msg = "<?php echo $this->translator->translator('common_publish_perm'); ?>";
				openMsgDialog(msg);
		<?php } ?>
	});
	
	$('a.publish_all').click(function() {
		var self = this;
		<?php if ($permission_arr['publish_enable']) { ?>
		if($('input.check_btn:checked').length > 0)
		{
			var article_id_str = '';
			for(var i=0;i < $('input.check_btn:checked').length;i++)
			{
				if(i == 0)
				{
					 article_id_str += $('input.check_btn:checked:eq('+i+')').val();
				}
				else
				{
					article_id_str += ','+$('input.check_btn:checked:eq('+i+')').val();
				}
			}
			
			$.ajax({
					url: "<?php echo $this->url( array('module'=> 'Articles', 'controller' => 'backend', 'action'     => 'publishall' ), 'adminrout',    true) ?>",
				 	type: 'POST',
				 	data: { article_id_st: article_id_str},
					beforeSend: function(){
						$(self).html('<span class="icon loader"></span>');
					 },
					success: function(response) 
				 	{
						//alert(response);
						var json_arr = eval("("+response+")");
						if(json_arr.status == 'ok')
						{
							for(var i=0;i < $('input.check_btn:checked').length;i++)
							{								
								//$('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").html('<?php echo $this->translator->translator("common_published_language"); ?>');
								var rel = $('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").children("a:nth-child(1)").attr('rel');
								var rel_arr = rel.split('_');
								var new_rel = rel_arr[0]+'_'+rel_arr[1]+'_unpublish';
								$('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").children("a:nth-child(1)").attr('rel',new_rel);
								$('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").children("a:nth-child(1)").html('<img src="application/modules/Administrator/layouts/scripts/images/tools/published.gif" border="0" title="<?php echo $this->translator->translator("common_unpublish_title"); ?>" />');								
							}

						}
						else
						{
							openMsgDialog(json_arr.msg);
						}	
						$(self).html('<span class="icon publish"><?php echo $this->translator->translator("common_publish_selected"); ?></span>');
					},
					error: function(xhr, status, error){				
						var msg = "Error! " + xhr.status + " " + error;
						openMsgDialog(msg);
					}
			});			
		}
		else
		{
			var msg = "<?php echo $this->translator->translator('article_selected_err'); ?>";
			openMsgDialog(msg);
		}
		<?php }else{ ?>
			var msg = "<?php echo $this->translator->translator('common_publish_perm'); ?>";
				openMsgDialog(msg);
		<?php } ?>
	});
	
	$('a.unpublish_all').click(function() {
		var self = this;
		<?php if ($permission_arr['publish_enable']) { ?>
			if($('input.check_btn:checked').length > 0)
			{
				var article_id_str = '';
				for(var i=0;i < $('input.check_btn:checked').length;i++)
				{
					if(i == 0)
					{
						 article_id_str += $('input.check_btn:checked:eq('+i+')').val();
					}
					else
					{
						article_id_str += ','+$('input.check_btn:checked:eq('+i+')').val();
					}
				}
				
				$.ajax({
						url: "<?php echo $this->url( array('module'=> 'Articles', 'controller' => 'backend', 'action'     => 'unpublishall' ), 'adminrout',    true) ?>",
						type: 'POST',
						data: { article_id_st: article_id_str},
						beforeSend: function(){
							$(self).html('<span class="icon loader"></span>');
						 },
						success: function(response) 
						{
							//alert(response);
							var json_arr = eval("("+response+")");
							if(json_arr.status == 'ok')
							{
								for(var i=0;i < $('input.check_btn:checked').length;i++)
								{								
									//$('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").html('<?php echo $this->translator->translator("common_unpublished_language"); ?>');
									var rel = $('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").children("a:nth-child(1)").attr('rel');
									var rel_arr = rel.split('_');
									var new_rel = rel_arr[0]+'_'+rel_arr[1]+'_publish';
									$('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").children("a:nth-child(1)").attr('rel',new_rel);
									$('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").children("a:nth-child(1)").html('<img src="application/modules/Administrator/layouts/scripts/images/tools/unpublished.gif" border="0" title="<?php echo $this->translator->translator("common_publish_title"); ?>" />');								
								}
	
							}
							else
							{							
								openMsgDialog(json_arr.msg);
							}	
							$(self).html('<span class="icon unpublish"><?php echo $this->translator->translator("common_unpublish_selected"); ?></span>');
						}
				});			
			}
			else
			{
				var msg = "<?php echo $this->translator->translator('article_selected_err'); ?>";
				openMsgDialog(msg);
			}
		<?php }else{ ?>
			var msg = "<?php echo $this->translator->translator('common_publish_perm'); ?>";
				openMsgDialog(msg);
		<?php } ?>
	});
	
	function deleteAll(self)
		{
			var article_id_str = '';
			for(var i=0;i < $('input.check_btn:checked').length;i++)
			{
				if(i == 0)
				{
					 article_id_str += $('input.check_btn:checked:eq('+i+')').val();
				}
				else
				{
					article_id_str += ','+$('input.check_btn:checked:eq('+i+')').val();
				}
			}
			
			$.ajax({
					url: "<?php echo $this->url( array('module'=> 'Articles', 'controller' => 'backend', 'action'     => 'deleteall' ), 'adminrout',    true) ?>",
				 	type: 'POST',
				 	data: { article_id_st: article_id_str},
					beforeSend: function(){
						$(self).html('<span class="icon loader"></span>');
					 },
					success: function(response) 
				 	{
						//alert(response);
						var json_arr = eval("("+response+")");
						if(json_arr.status == 'ok')
						{
							for(var i= ($('input.check_btn:checked').length-1);i >= 0;i--)
							{								
								$('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").addClass('row_selected');									
							}
							var oTabled = $('#sortTable').dataTable();
							var anSelected = fnGetSelected( oTabled );
							for(var k = 0; k < anSelected.length; k++)
							{
								oTabled.fnDeleteRow( anSelected[k] );
							}
						}
						else
						{							
							openMsgDialog(json_arr.msg);
							
						}	
						$(self).html('<span class="icon delete"><?php echo html_entity_decode($this->translator->translator("common_delete_selected"), ENT_QUOTES, "UTF-8"); ?></span>');
					}
			});	
		}
	
	$('a.delete_all').click(function() {
		var self = this;
		if($('input.check_btn:checked').length > 0)
		{
			$("#dialog-confirm").html("<?php echo addslashes($this->translator->translator('article_list_delete_confirm')); ?>").dialog({
					resizable: false,
					width:400,
					height:170,
					modal: true,
					show: 'fade',
					hide: 'explode',
					buttons: {
							'<?php echo html_entity_decode($this->translator->translator("common_delete_selected"), ENT_QUOTES, "UTF-8"); ?>': function() {
							deleteAll(self);
							$(this).dialog('close');
						},
					'<?php echo html_entity_decode($this->translator->translator("common_cancel"), ENT_QUOTES, "UTF-8"); ?>': function() {
							$(this).dialog('close');
						}
					}
				});		
		}
		else
		{
			var msg = "<?php echo $this->translator->translator('article_selected_err'); ?>";
			openMsgDialog(msg);
		}
	});
	
	$('input.checkAll_btn').click(function() {
		var self = this;
		if($(self).is(':checked'))
		{		
			$('input.check_btn').attr('checked', true);
		}
		else
		{
			$('input.check_btn').attr('checked', false);
		}
	});
			
});
</script>
<?php
echo $this->headScript()->appendFile($this->baseUrl().'/js/jquery/colorbox/jquery.colorbox.js');
?>
<script type="text/javascript">
$(document).ready(function() {
	$("a[rel='preview_btn']").colorbox({width:"98%", height:"98%",slideshow:false, transition:"fade"});	
});
</script>
<?php if (!$this->allow('list')) : ?>
<div class="grid_12 t_a_bottom">
		<?php echo $this->translator->translator('Member_Access_deny_desc'); ?>
</div>
<?php else : ?>
<div id="container">

<div class="title-container">
	<div class="article"><h1><?php if($this->draft_page == '0'){ echo $this->translator->translator('article_list_draft_page_name'); }else{ echo $this->translator->translator('article_list_page_name'); } ?></h1></div>
    
    <div class="button-container">
        <?php if ($permission_arr['add_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="<?php echo $this->url(array('module'=> 'Articles','controller'=>'Backend', 'action'=>'add'),'adminrout',true);?>"><span class="icon add"><?php echo $this->translator->translator('common_add'); ?></span></a></span>
        <?php endif; ?>
        <?php if ($permission_arr['publish_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" class="publish_all"><span class="icon publish"><?php echo $this->translator->translator('common_publish_selected'); ?></span></a></span>
        <?php endif; ?>
        <?php if ($permission_arr['publish_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" class="unpublish_all"><span class="icon unpublish"><?php echo $this->translator->translator('common_unpublish_selected'); ?></span></a></span>
        <?php endif; ?>
        <?php if ($permission_arr['delete_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" class="delete_all"><span class="icon delete"><?php echo html_entity_decode($this->translator->translator("common_delete_selected"), ENT_QUOTES, "UTF-8"); ?></span></a></span>
        <?php endif; ?>
    </div>
</div>
<div id="button_top_bar"></div>

<div class="content-container">
	<p>
		<?php echo $this->translator->translator('article_list_tips_desc'); ?>
    </p>
    <br />
	<div class="pagination">
		<?php echo $this->paginationControl($this->article_datas, 'Sliding', 'backend/top_pagination.phtml'); ?>
    </div>
    
    <div class="chart">
		<div class="data-table">
        	<table id="sortTable" width="100%" align="center" cellpadding="0" cellspacing="0">
	   		<thead>
				<tr>
		  			<th width="3%"><input type="checkbox" name="checkAll" id="checkAll" class="checkAll_btn" /></th>
                  	<th width="4%"><?php echo $this->translator->translator('common_id'); ?></th>
                  	<th width="31%"><?php echo $this->translator->translator('article_list_page_title'); ?></th>                                
                  	<th width="22%"><?php echo $this->translator->translator('articles_join_with_menu'); ?></th> 
                  	<th width="9%">
						<?php echo $this->translator->translator('common_order'); ?>											
						<a href="javascript: void(0);" class="all_order_btn"><img src="application/modules/Administrator/layouts/scripts/images/tools/save.png" border="0" /></a>		  			</th>
		  			<th width="7%"><?php echo $this->translator->translator('common_status'); ?></th>
	  			  <th width="11%"><?php echo $this->translator->translator('article_list_page_created_date'); ?></th>
		  			<th width="13%"><?php echo $this->translator->translator('common_action'); ?></th>
				</tr>
			</thead>
			<tbody>
			<?php 
            $mem_db = new Members_Model_DbTable_MemberList();
            $j = 1;
            foreach ($this->article_datas as $entry): 
                if($j % 2 == 0)
                {
                    $onmouseout = "this.bgColor='#FFFFFF';";
                    $background = '#FFFFFF';
                }
                else
                {
                    $onmouseout = "this.bgColor='#F7F7F7';";
                    $background = '#F7F7F7';
                }
				$member_info = $mem_db->getMemberInfo($this->escape($entry->entry_by));
				$linked_menus = Menu_View_Helper_SubMenu::getSelectedMenuList($this->escape($entry->article_id));
				$linked_menu_arr = array();
				if($linked_menus)
				{
					foreach($linked_menus as $linke_key => $linked_arr)
					{
						$linked_menu_arr[$linke_key]  = $this->escape($linked_arr['menu_name']).' ('.$linked_arr['group_id'].')';
					}
				}
            ?>
				<tr bgcolor="<?php echo $background; ?>" onmouseover="this.bgColor='#FCF5DD';" onmouseout="<?php echo $onmouseout; ?>">
		  			<td class="center checkbox"><input type="checkbox" name="checkbtn" id="checkbtn" value="<?php echo $this->escape($entry->article_id); ?>" class="check_btn" /></td>
		  			<td class="center"><?php echo $this->escape($entry->article_id); ?></td>
		  			<td><?php echo $this->escape($entry->article_name); //if($this->link_menu == '1'){?><!--<div class="select-btn ui-widget-content-1 right-float"><a href="<?php //echo $this->url(array('module'=> 'Menu','controller'=>'backend', 'action'=>'add', 'article_id' => $this->escape($entry->article_id)),'adminrout',true);?>"><span class="icon link"><?php //echo $this->translator->translator('articles_link_to_menu'); ?></span></a></div>--><?php //} ?></td>
		 			<td title="<?php echo '<strong>'.$this->translator->translator('common_entry_by').':</strong> '. $this->escape($member_info['username']); ?>">
                    <?php
                    	echo implode('&nbsp;&nbsp; ||  &nbsp;&nbsp;', $linked_menu_arr);						
					?>
                    </td>		
		  			<td class="center">
						<input type="text" size="1" name="order" id="order" class="order_text" value="<?php echo $this->escape($entry->order); ?>" />
						<a href="javascript: void(0);" rel="<?php echo $this->escape($entry->article_id); ?>" class="up_btn"><img src="application/modules/Administrator/layouts/scripts/images/tools/up-arrow.gif" border="0" /></a>&nbsp;<a href="javascript: void(0);" rel="<?php echo $this->escape($entry->article_id); ?>" class="down_btn"><img src="application/modules/Administrator/layouts/scripts/images/tools/down-arrow.gif"  border="0" /></a>		
		  			</td>
		  			<td class="center">
            			<a href="javascript:void(0);" class="publish_btn" rel="<?php echo $this->escape($entry->article_id); ?>_<?php echo $this->escape($entry->article_title); ?>_<?php if($this->escape($entry->article_status=='1')){ ?>unpublish<?php }else{ ?>publish<?php } ?>"><?php if($this->escape($entry->article_status=='1')){ ?><img src="application/modules/Administrator/layouts/scripts/images/tools/published.gif" border="0" title="<?php echo $this->translator->translator('common_unpublish_title'); ?>" /><?php }else{ ?><img src="application/modules/Administrator/layouts/scripts/images/tools/unpublished.gif" border="0" title="<?php echo $this->translator->translator('common_publish_title'); ?>" /><?php } ?></a>
          			</td>
		  			<td class="center"><?php echo $this->escape($entry->article_date); ?></td>
		  			<td class="tools-list">
                   		<ul>
                        <?php
							if($this->link_menu == '1')
							{
								echo '<li><a href="'.$this->url(array('module'=> 'Menu','controller'=>'backend', 'action'=>'add', 'article_id' => $this->escape($entry->article_id)),'adminrout',true).'"><img src="application/modules/Administrator/layouts/scripts/images/tools/hotels/link.png" title="'.$this->translator->translator('articles_link_to_menu').'" alt="'.$this->translator->translator('articles_link_to_menu').'"  border="0" /></a></li>';
							}
						?>
						<?php if ($permission_arr['edit_enable']) : ?>
							<li><a href="<?php echo $this->url( array('module'=> 'Articles', 'controller' => 'backend', 'action'     => 'edit', 'article_id' => $this->escape($entry->article_id) ), 'adminrout',    true) ?>"><img src="application/modules/Administrator/layouts/scripts/images/tools/edit.png" title="<?php echo $this->translator->translator('common_edit_title'); ?>" border="0" /></a></li>
						<?php endif; ?>
	
						<?php if ($permission_arr['delete_enable']) : ?>
							<li><a href="javascript:void(0);" class="delete_btn"  rel="<?php echo $this->escape($entry->article_id); ?>_<?php echo $this->escape($entry->article_title); ?>"><img src="application/modules/Administrator/layouts/scripts/images/tools/delete.png" title="<?php echo $this->translator->translator('common_delete_title'); ?>" border="0" /></a></li>
						<?php endif; ?>
			 		
						<?php if ($this->allow('preview','backend','Articles')) : ?>
							<li><a  rel="preview_btn" href="<?php echo $this->url( array('module'=> 'Articles', 'controller' => 'backend', 'action'     => 'preview', 'article_id' => $this->escape($entry->article_id) ), 'adminrout',    true) ?>" ><img src="application/modules/Administrator/layouts/scripts/images/tools/preview.gif" border="0" title="<?php echo $this->translator->translator('common_preview_title'); ?>" /></a></li>
						<?php endif; ?>
                        </ul>
                  	</td>
				</tr>
			
			<?php 
				$j++;
				endforeach;	
		  	?>
	   		</tbody>
			</table>	
		</div>
	</div>
    
    <div class="pagination">
    	<?php echo $this->paginationControl($this->article_datas, 'Sliding', 'backend/pagination.phtml'); ?>
    </div>
</div>

<div id="floatingbar">
	<h1><?php if($this->draft_page == '0'){ echo $this->translator->translator('article_list_draft_page_name'); }else{ echo $this->translator->translator('article_list_page_name'); } ?></h1>
    
    <div class="button-container">
        <?php if ($permission_arr['add_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="<?php echo $this->url(array('module'=> 'Articles','controller'=>'Backend', 'action'=>'add'),'adminrout',true);?>"><span class="icon add"><?php echo $this->translator->translator('common_add'); ?></span></a></span>
        <?php endif; ?>
        <?php if ($permission_arr['publish_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" class="publish_all"><span class="icon publish"><?php echo $this->translator->translator('common_publish_selected'); ?></span></a></span>
        <?php endif; ?>
        <?php if ($permission_arr['publish_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" class="unpublish_all"><span class="icon unpublish"><?php echo $this->translator->translator('common_unpublish_selected'); ?></span></a></span>
        <?php endif; ?>
        <?php if ($permission_arr['delete_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" class="delete_all"><span class="icon delete"><?php echo html_entity_decode($this->translator->translator("common_delete_selected"), ENT_QUOTES, "UTF-8"); ?></span></a></span>
        <?php endif; ?>
    </div>
</div>
</div>
<?php endif; ?>	
<div id="dialog_container" title="<?php echo $this->translator->translator('common_dialog_msg',$this->translator->translator('article_list_page_name')); ?>"></div>
<div id="dialog-confirm" title="<?php echo $this->translator->translator('common_confirmation',$this->translator->translator('common_delete')); ?>"></div>